<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>代码压缩与美化</title>
  <style type="text/css">
    button {margin-left: 8px;padding: 3px 6px;}
    textarea {width: 98%;}
    .actions {margin-top: 12px;margin-bottom: 12px;padding-left: 8%;}
    .split {margin-left: 12px;margin-right: 4px;}
    .upload {border: 1px solid #FFFBB6;background-color: #FFFBB6;}
    .compress, .beautify {border-color: #0073cc;background-color: #0073cc;color: #fff;}
    .pasteCode, .copyCode, .emptyCode, .save {color: #09f;}
    .pasteCode {display: none;}
    .rate {margin-top: 12px;padding-left: 15px;color: #075F37;}
    .api-title {margin-top: 35px;font-weight: normal;}
    #clipboard-container {opacity: 0;position: absolute;top: -10000px;right: 0;}
    #clipboard {width: 1px; height: 1px; padding: 0px;}
  </style>
</head>
<body>
  <h1>JS代码压缩，JS、CSS、HTML美化</h1>

  <div class="actions" data-target="input">
    <input type="file" class="upload" accept=".js" />
    <button type="button" class="compress" id="uglify">压缩JS</button>
    <button type="button" class="compress" id="jspacker">JSPacker加密</button>
    <span class="split">|</span>
    <button type="button" class="pasteCode">粘贴</button>
    <button type="button" class="copyCode">复制</button>
    <button type="button" class="emptyCode">清空</button>
    <button type="button" class="save">另存为</button>
    <div class="rate"></div>
  </div>
  <textarea id="input" rows="20" spellcheck="false"></textarea>
  <hr>
  <div class="actions" data-target="output">
    <input type="file" class="upload" accept=".js,.css,.html,.htm" />
    <button type="button" class="beautify" data-type="js">美化JS</button>
  <button type="button" class="beautify" data-type="css">美化CSS</button>
  <button type="button" class="beautify" data-type="html">美化HTML</button>
    <span class="split">|</span>
    <button type="button" class="pasteCode">粘贴</button>
    <button type="button" class="copyCode">复制</button>
    <button type="button" class="emptyCode">清空</button>
    <button type="button" class="save">另存为</button>
  </div>
  <textarea id="output" rows="12" spellcheck="false"></textarea>

  <h4 class="api-title">API调用说明：</h4>
  <ul class="api">
    <li>均为POST请求；请求的数据即body内容；返回内容为处理结果或错误信息。</li>
    <li>JS压缩：利用uglify压缩JS源文件。URL: <span class="js-location"></span>uglify</li>
    <li>JSPacker加密：混淆加密。URL: <span class="js-location"></span>jspacker</li>
    <li>JS美化：以较美观的形式格式化JS代码，下同。URL: <span class="js-location"></span>beautify?type=js</li>
    <li>CSS美化。URL: <span class="js-location"></span>beautify?type=css</li>
    <li>HTML美化。URL: <span class="js-location"></span>beautify?type=html</li>
    <li>jQuery调用示例：<code>
      $.post('<span class="js-location"></span>uglify', 'JS源代码', function(data) {
        /* data是压缩后的js代码或错误信息 */
      });</code></li>
  </ul>

  <div id="clipboard-container"><textarea id="clipboard"></textarea></div>

  <script src="http://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
  <script src="code-formatter.js"></script>
</body>
</html>